Skip to content

Comments

Add support for YAML-based config#1491

Draft
Copilot wants to merge 9 commits intomainfrom
copilot/add-yaml-config-support
Draft

Add support for YAML-based config#1491
Copilot wants to merge 9 commits intomainfrom
copilot/add-yaml-config-support

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

Adds YAML as an alternative to JSON for all configuration files. Supports YAML anchors and merge keys for reusable configuration blocks.

New Files

  • DevProxy.Abstractions/Utils/ProxyYaml.cs - YAML-to-JSON conversion with anchor/alias/merge key support
  • DevProxy.Abstractions/Extensions/YamlConfigurationExtensions.cs - ASP.NET Core IConfigurationProvider for YAML files
  • DevProxy/devproxyrc.yaml - YAML version of default configuration (reference example)
  • DevProxy/devproxy-errors.yaml - YAML version of default error responses (reference example demonstrating anchors)

Modified Files

  • ConfigurationManagerExtensions.cs - Added devproxyrc.yaml/.yml to config file discovery
  • BaseLoader.cs - Convert YAML plugin configs to JSON before processing
  • ConfigCommand.cs - Detect YAML config/mock files in downloaded samples
  • DevProxy.csproj - Include YAML config files in build output and installer

Features

  • .yaml and .yml extensions supported everywhere JSON is used
  • YAML 1.1 boolean values (yes/no, on/off, true/false)
  • Full anchor/alias support with merge key precedence (explicit values override merged)

Example

definitions:
  throttled: &throttled
    statusCode: 429
    body: '{"error": "Too many requests"}'

mocks:
  - request:
      url: https://graph.microsoft.com/v1.0/users
    response:
      <<: *throttled
  - request:
      url: https://graph.microsoft.com/v1.0/groups
    response:
      <<: *throttled

Backward compatible—existing JSON configuration continues to work unchanged.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for YAML-based config</issue_title>
<issue_description>Support both JSON- and YAML-based config.

YAML would be particularly beneficial for including comments (although they are supported in JSONC, but that's not always obvious) and multiline strings (ie. mocks).

One more thing that would be beneficial are anchors for repeated patterns:

definitions:
  throttled: &throttled
    statusCode: 429
    body: '{"error": "Too many requests"}'

responses:
  - url: https://graph.microsoft.com/v1.0/users
    <<: *throttled
  - url: https://graph.microsoft.com/v1.0/groups
    <<: *throttled

Notice how for both responses we reuse the same definition, significantly simplifying the config.

YAML config should be supported everywhere where we allow JSON-based config (root, plugins, etc)</issue_description>

Comments on the Issue (you are @copilot in this section)

@garrytrinder Nice idea! Let's do it 💪

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add support for YAML-based configuration Add support for YAML-based config Jan 13, 2026
Copilot AI requested a review from waldekmastykarz January 13, 2026 13:40
Copy link
Collaborator

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot have you also considered supporting YAML in config files for plugins, like mocks, CRUD API, etc?

Copy link
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot have you also considered supporting YAML in config files for plugins, like mocks, CRUD API, etc?

Yes, YAML is already supported for all plugin config files. The BaseLoader class (which all loaders like MockResponsesLoader, CrudApiDefinitionLoader, etc. inherit from) automatically detects .yaml/.yml files and converts them to JSON before processing.

Users can specify YAML files for mocks, CRUD API definitions, error responses, rate limiting configs, and all other plugin-specific configuration files - they just need to use the .yaml or .yml extension.

Copy link
Collaborator

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI requested a review from waldekmastykarz January 14, 2026 11:47
@waldekmastykarz waldekmastykarz marked this pull request as ready for review February 22, 2026 10:22
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner February 22, 2026 10:22
Copilot AI review requested due to automatic review settings February 22, 2026 10:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class YAML support for Dev Proxy configuration files so users can author configs in either JSON/JSONC or YAML (including anchors and merge keys), while keeping existing JSON configs working.

Changes:

  • Added a YAML-to-JSON conversion utility (ProxyYaml) and a YAML IConfigurationProvider for loading root config from .yaml/.yml.
  • Updated config file discovery/loading to recognize devproxyrc.yaml/.yml and route through a new AddConfigFile helper.
  • Updated sample config/mock detection to include YAML files when scanning downloaded config folders.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
DevProxy/Extensions/ConfigurationManagerExtensions.cs Adds .yaml/.yml to devproxyrc discovery and uses AddConfigFile for JSON/YAML loading.
DevProxy/Commands/ConfigCommand.cs Expands sample config/mock detection to include YAML files.
DevProxy.Abstractions/Utils/ProxyYaml.cs Introduces YAML-to-JSON conversion with merge-key handling and scalar typing.
DevProxy.Abstractions/Plugins/BaseLoader.cs Converts YAML plugin/mock files to JSON before schema validation and parsing.
DevProxy.Abstractions/Extensions/YamlConfigurationExtensions.cs Adds YAML configuration source/provider and AddConfigFile extension method.

Copilot AI and others added 6 commits February 22, 2026 13:45
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
… normalization

- Handle nested merge keys recursively in CollectMergedValues instead of skipping them
- Distinguish quoted empty strings from null using ScalarStyle in ProxyYaml
- Normalize YAML 1.1 booleans (yes/no/on/off) to true/false in YamlConfigurationProvider
@waldekmastykarz waldekmastykarz force-pushed the copilot/add-yaml-config-support branch from 66b37c6 to a0204d8 Compare February 22, 2026 12:45
Copy link
Contributor

@garrytrinder garrytrinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include an example default YAML configuration file alongside the existing devproxyrc.json file?

@waldekmastykarz
Copy link
Collaborator

Should we include an example default YAML configuration file alongside the existing devproxyrc.json file?

Good idea. It wouldn't be used, but it would be a good reference for folks.

@waldekmastykarz
Copy link
Collaborator

Should we include an example default YAML configuration file alongside the existing devproxyrc.json file?

Good idea. It wouldn't be used, but it would be a good reference for folks.

@copilot Add a YAML version of the default configuration (https://github.com/dotnet/dev-proxy/blob/main/DevProxy/devproxyrc.json and https://github.com/dotnet/dev-proxy/blob/main/DevProxy/devproxy-errors.json). Ensure, that both files are copied to the output on building and included in the installer.

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

Should we include an example default YAML configuration file alongside the existing devproxyrc.json file?

Good idea. It wouldn't be used, but it would be a good reference for folks.
...

Added in c02bc37:

  • devproxyrc.yaml - YAML version of the default config
  • devproxy-errors.yaml - YAML version of error responses (demonstrates YAML anchors)

Both files are copied to output on build and will be included in the installer automatically (since the installer copies all files from the build output directory).

Copy link
Contributor

@garrytrinder garrytrinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got some issues with validation for files and plugins in YAML.

# It demonstrates YAML features like comments, multiline strings, and anchors.

# Define reusable error body templates using YAML anchors
definitions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in an diagnostic error in VS Code when a YAML language server is present.

Image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema validation is skipped for both the config file and plugin.

Image

@garrytrinder garrytrinder marked this pull request as draft February 23, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for YAML-based config

3 participants